-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(spans-migration): add selection params to explore url in frontend #101185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
params.push('utc=true'); | ||
} | ||
|
||
selection.projects.forEach(project => { | ||
params.push(`project=${project}`); | ||
}); | ||
|
||
selection.environments.forEach(environment => { | ||
params.push(`environment=${environment}`); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential bug: URL parameters are not encoded, leading to broken links for environment names with special characters.
-
Description: The
createExploreUrl
function constructs URL parameters without encoding them. Since environment names can contain special characters like '&', '=', or spaces, concatenating them directly into the URL string will result in malformed and broken URLs. This impacts the functionality of the 'Explore' links for users with such environment names. -
Suggested fix: Use
encodeURIComponent
on the values of the parameters before adding them to the URL string. For example, changeparams.push(
environment=${environment});
toparams.push(
environment=${encodeURIComponent(environment)});
.
severity: 3.0, confidence: 5.0
Did we get this right? 👍 / 👎 to inform future reviews.
if (selection.datetime?.start) { | ||
params.push(`start=${getUtcDateString(selection.datetime.start)}`); | ||
} | ||
if (selection.datetime?.end) { | ||
params.push(`end=${getUtcDateString(selection.datetime.end)}`); | ||
} | ||
if (selection.datetime?.period) { | ||
params.push(`statsPeriod=${selection.datetime.period}`); | ||
} | ||
if (selection.datetime?.utc) { | ||
params.push('utc=true'); | ||
} | ||
|
||
selection.projects.forEach(project => { | ||
params.push(`project=${project}`); | ||
}); | ||
|
||
selection.environments.forEach(environment => { | ||
params.push(`environment=${environment}`); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels a little janky to me, could we instead parse this URL, something like
const parsedURL = safeURL(baseUrl);
const queryParams = qs.parse(parsedURL?.search ?? '');
// append all the page filters to queryParams - perhaps use an existing util like pageFiltersToQueryParams
return getExploreUrl(queryParams)
queryParams.aggregateField = queryParams.aggregateField.map(item => | ||
JSON.parse(item) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: JSON Parsing Errors in createExploreUrl
The createExploreUrl
function calls JSON.parse()
on aggregateField
values without validation or error handling. This can lead to runtime errors and component crashes if the aggregateField
parameter contains malformed JSON strings or if array elements are not strings.
add the page params to the transaction widget warning urls on the frontend so they can see the same thing if they haven't submitted their dashboard filters. NOTE: i noticed that now the entire dashboard reloads when changing dashboard filters because the urls have to be re-rendered. This kinda sucks but it will be temporary